package com.example.androiddemo;

import com.demo.asyncloaderimage.AsynImageLoader;
import com.demo.customviewgroup.CustomViewGroupActivity;
import com.demo.drawlayout.MainFrameLayout;
import com.demo.mvp.MVPActivity;
import com.iving.ui.util.ToastUtils;
import com.iving.util.LogUtils;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

public class MainActivity extends Activity {

  private ImageView mImagView;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.d("test", "-------onCreate------");
    if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
      Log.d("test", "onCreate--->ORIENTATION_PORTRAIT");
    } else if (this.getResources()
        .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      Log.d("test", "onCreate--->ORIENTATION_LANDSCAPE");
    }
    this.setRequestedOrientation(Configuration.ORIENTATION_LANDSCAPE);
    setContentView(R.layout.activity_main);
    initView();

  }

  private void initView() {
    mImagView = (ImageView) this.findViewById(R.id.imageView1);

  }


  public void onClick(View view) {

    // testWebview();
    // testCustomViewGroup();
    // testDrawlayout();
    // testAsynImageLoader();
    testMVP();
  }

  private void testMVP(){
    Intent intent= new Intent(this,MVPActivity.class);
    
    this.startActivity(intent);
  }



  private void testAsynImageLoader() {

    AsynImageLoader asynImageLoader = new AsynImageLoader();
    String imageUrl = "http://cache.soso.com/30d/img/web/logo.gif";
    asynImageLoader.showImageAsyn(mImagView, imageUrl, R.drawable.ic_launcher);
  }


  private void testWebview() {
    LogUtils.w("the first jar test from android");
    ToastUtils.showLong(this, "a test jar by sheli");
    Intent intent = new Intent(MainActivity.this, WebViewActivity.class);
    this.startActivity(intent);
  }

  private void testCustomViewGroup() {
    Intent intent = new Intent(MainActivity.this, CustomViewGroupActivity.class);
    this.startActivity(intent);
  }

  // MainFrameLayout
  private void testDrawlayout() {
    Intent intent = new Intent(MainActivity.this, MainFrameLayout.class);
    this.startActivity(intent);
  }

  @Override
  protected void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
    Log.d("test", "onDestroy");

  }
}
